﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace ProcedureControlApi.DbContext
{
    public class ProcedureServerContext: Microsoft.EntityFrameworkCore.DbContext
    {
        public DbSet<Server> Servers { get; set; }

        public string DbPath { get; private set; }

        public ProcedureServerContext()
        {
            //var folder = Environment.SpecialFolder.LocalApplicationData;
            //var path = Environment.GetFolderPath(folder);
            //DbPath = $"{path}{System.IO.Path.DirectorySeparatorChar}ProcedureServer.db";
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite($"Data Source=ProcedureServer.db");
        }
    }
    /// <summary>
    /// 服务类型
    /// </summary>
    public enum ServerTypeEnum
    {
        service=0,
        website=1
    }
    public class Server
    {
        /// <summary>
        /// id 主键
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 服务名 服务程序就是服务名 iis下就是website名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } 
        /// <summary>
        /// 服务类型
        /// </summary>
        public ServerTypeEnum ServerType { get; set; }
        /// <summary>
        /// 最后心跳时间
        /// </summary>
        public DateTime LastHeartbeatTime { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDelete { get; set; } 
        /// <summary>
        /// 是否在线
        /// </summary>
        public bool IsOnline { get; set; } 
    }

}
